package com.xplay.xpocker.util;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class StringUtils {
    static List<String> toList(String data, String splitStr) {
        if (data == null || data.equals("")) {
            return new ArrayList<>();
        }
        return Arrays.stream(data.split(splitStr)).collect(Collectors.toList());
    }

    static String toStr(List<Object> data, String splitStr) {
        if (data == null || data.size() == 0) {
            return "";
        }
        StringBuffer buffer = new StringBuffer();
        for (Object item : data) {
            buffer.append(item.toString());
            buffer.append(splitStr);
        }
        buffer.deleteCharAt(buffer.length() - 1);
        return buffer.toString();
    }
}
